package com.squirrel.michale;

/**
 * @author guanhao 观浩
 * @version 1.0.0.0
 * @createTime 2023/2/1 5:30 PM
 * @company Michale Squirrel
 * @link
 * @description
 */
public class LCP68 {


    public int beautifulBouquet(int[] flowers, int cnt) {
        int sum = 0;
        int[] countArray = new int[1000001];
        for (int left = 0, right = 0; right < flowers.length; right++) {
            countArray[flowers[right]]++;
            while (countArray[flowers[right]] > cnt) {
                countArray[flowers[left]]--;
                left++;
            }
            sum += right - left + 1;
        }
        return sum % 1000000007;
    }

}
